@using PagedList.Mvc
@using MvcHtmlHelpers
@model SampleWebsite.Mvc3.Areas.MvcMembership.Models.UserAdministration.IndexViewModel
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href='@Url.Content("~/Content/PagedList.css")' rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(function () {
        $("a.action").button();
    });

    
</script>
@if (!Model.IsRolesEnabled)
{

    <span>WARNING: Your Role Provider is currently disabled - any user may currently visit
        this page.</span>
}
<h3>
    System <span class="accent">Administration</span>
</h3>
 
 <h4>
    Users: @*<span class="accent">Administration</span>*@
</h4>

<form method="get">
<fieldset>
    <legend>Find a User</legend>
    <label>
        User Name or Email Address:
        <input type="text" name="search" value="@Model.Search" />
        <input type="submit" value="Search" />
        @if (!string.IsNullOrWhiteSpace(Model.Search))
        { 
            <span>(@Html.ActionLink("Clear Search", "Index"))</span>
        }
    </label>
</fieldset>
</form>
@*@Html.ActionLink("New User", "CreateUser", "UserAdministration", new { @id = "CreateLink" })*@
<div style="margin-top: 20px">
    @if (Model.Users.Count > 0)
    {

        <table>
            <tr>
                <th>
                </th>
                <th>
                    User Name
                </th>
                <th>
                    E-mail
                </th>
                <th>
                    Activity
                </th>
                <th>
                    Comment
                </th>
            </tr>
            @foreach (var user in Model.Users)
            {
                <tr>
                    <td>
                        @Html.ActionLink("Details", "Details", new { id = user.ProviderUserKey }, new { @class = "action" })
                    </td>
                    <td>
                        @user.UserName
                    </td>
                    <td>
                    @user.Email
                        <div id="email" style="display: inline-block" @*class="ui-state-default ui-corner-all-email"*@>
                            <a href="mailto:@user.Email" class="ui-icon ui-icon-mail-closed">mail</a>
                        </div>
                    </td>
                    <td>
                        @if (user.IsOnline)
                        {
                            <span class="accent">Online</span>
                        }
                        else
                        {
                            <span>Offline for @Html.TimePeriod(user.LastActivityDate)</span>
                        }
                    </td>
                    <td>
                        @user.Comment
                    </td>
                </tr>
            }
        </table>
	@Html.PagedListPager(Model.Users, page => Url.Action("Index", new { page, search = Model.Search }))
    }
    else
    {

        <p>
            No users have registered.</p>
    }
</div>

<h4>
    Roles: @*<span class="accent">Administration</span>*@
</h4>

<table style="width: auto">
            <tr>
                <th>
                    Role Name
                </th>
                <th>
                    View Users
                </th>
            </tr>
            @foreach (var role in Model.Roles)
            {
                <tr>
                    <td>
                        @role.
                    </td>
                    <td>
                        @Html.ActionLink(role, "Role", new { id = role }, new { @class = "ui-icon ui-icon-search" })
                    </td>
                </tr>
            }
        </table>
